The script engine executes based on the structure of the destination data definition. This is termed the program flow and is the order in which the See "Events" are executed by the script engine.
The script engine executes based on this destination data definition, running through its datasets and fields executing the events. This happens in a predetermined order however it is possible for the user to control this order of execution with special functions in the script.
To describe the program flow it is best to illustrate it with an example. Mapping is about converting a source data definition into a destination data definition. For the purpose of the example we have the following data definitions. The source data definition is reading from a Informix database, and the destination is connected to a MSSQL database. The effect therefore
Within the map editor these data definitions are shown in a tree format representative of their hierarchy. The source data definition is on the left and the destination data definition is on the right
The script engine is based off the destination data definition and therefore when the map executes the following program flow occurs.
However the processing doesn't necessary have to finish there (and most likely it won't). What happens next depends on whether the LinkedData event is set for any of the datasets (Refer See "Events"). The LinkedData event is a special event that indicates whether a source dataset is linked to this dataset.
When there is no LinkedData the destination dataset is processed once and therefore one record is created.
Let's now assume for this example that the equivalent source dataset is linked to the destination dataset (ie ORD_HEAD linked to ORDER_HEADER). The script engine will now scroll through the records of the linked source dataset until it comes to the end. If there is a child dataset however it processes that first before scrolling to the next record in the source.
A dataset has only one active record at a time. The script engine determines the end of the dataset when it sees no more records, however the script engine only sees the records in the child dataset that match to the parent dataset. When the mapping first starts, record 1 of the ORD_HEAD is active - the script engine only sees its 5 ORD_LINE records, of which the first one of these is active meaning the engine only sees the 2 LINE_MESG records for that active ORD_LINE record.
Remember that in this example the source dataset has 10 orders within it, each with 5 lines, and each of those with 2 messages. The following program flow will therefore occur:
In essence the first ORD_HEAD record is processed, then each of its ORD_LINE records, and each of the LINE_MESG records in between each line. Eventually the next ORD_HEAD is processed and the loop continues until no data is left in the source data definition.
The user can modify this program flow through special See "Program Control" functions in the script.